﻿using System;
using Fly.Data;
using FlyWebFrame.Model;

namespace FlyWebFrame.Action
{
    public class index : homeaction
    {
        public string upcomming_title;
        public dynamic features;
        public override void Treat()
        {
            renderLeftNav(20);
            content_right = "/html/home/right.htm";
            //renderListNews(20, 0, 15);
            renderLeftNav(3);
            renderFirstNews(3);
            content_right = "/html/home/righthome.htm";
            current_link = "index/" + other_lang;
            News news = new News();
            newslist = news.GetUpcomingCourses().Data;
            features = news.GetFeatured().Data;
            if (newslist == null && features == null)
            {
                content_right = "/html/home/right.htm";
            }
            if (newslist != null)
            {
                for (int i = 0; i < newslist.Length; i++)
                {
                    newslist[i].description = Fly.Util.Text.Shorten(newslist[i].description, 45);
                    
                    if (lang != "en")
                    {
                        newslist[i].title = newslist[i].viTitle;
                        newslist[i].description = Fly.Util.Text.Shorten(newslist[i].viDescription, 45);
                        newslist[i].detail = newslist[i].viDetail;
                        
                    }
                }
            }
            if (features != null)
            {
                for (int i = 0; i < features.Length; i++)
                {
                    features[i].description = Fly.Util.Text.Shorten(features[i].description, 45);
                    if (lang != "en")
                    {
                        features[i].title = features[i].viTitle;
                        features[i].description = Fly.Util.Text.Shorten(features[i].viDescription, 45);
                        features[i].detail = features[i].viDetail;
                        features[i].Date = this.ToVietnamDate(features[i].eventTime.DayOfWeek.ToString()) + ", " + features[i].eventTime.Day.ToString() + "/" + features[i].eventTime.Month.ToString() + "/" + features[i].eventTime.Year.ToString() + ", " + features[i].eventTime.Hour.ToString() + "h:" + features[i].eventTime.Minute.ToString();
                    }
                }
            }
            
        }
    }
}